package xyz.wjwnya.ask_for_leave_manage_module.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.wjwnya.ask_for_leave_manage_module.serivce.AskForLeaveManageService;
import xyz.wjwnya.ask_for_leave_manage_module.utils.DataMapper;
import xyz.wjwnya.ask_for_leave_manage_module.vo.AskForLeaveInfo;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/ask_for_leave/admin")
public class AdminAskForLeaveController {

    private final AskForLeaveManageService askForLeaveManageService;

    public AdminAskForLeaveController(AskForLeaveManageService askForLeaveManageService) {
        this.askForLeaveManageService = askForLeaveManageService;
    }

    @GetMapping("/ask/all")
    public List<AskForLeaveInfo> getAllAskForLeave() {
        return askForLeaveManageService.getAllAskForLeaveRecord()
                .stream().map(DataMapper::askDataToInfo).collect(Collectors.toList());
    }

}
